import { processComponent } from "./vnodes/component"
import { processElement } from "./vnodes/element"
import { ShapeFlag } from "./flags"
import { diff } from "./diff"
import type { vnode } from "../types"


export function mount() {}

export function patch(vnode:vnode, container:HTMLElement):void
export function patch(prevVNode:vnode, nextVNode:vnode, container:HTMLElement):void
export function patch(...args:unknown[]) {
  if(args.length === 2) {
    const [ vnode, container ] = args as [vnode, HTMLElement]
    const { shapeFlag } = vnode

    if(shapeFlag && shapeFlag === ShapeFlag.COMPONENT) {
      processComponent(null, args[0] as vnode)
    } else if(shapeFlag && shapeFlag === ShapeFlag.ELEMENT) {
      processElement(vnode, container)
    }
  } else {
    diff(args[0] as vnode, args[1] as vnode, args[2] as HTMLElement)
  }
}
